<div class="container-fluid" style="padding: 20px 10px 0px 10px">
    <div class="row-fluid">
        <div class="well">
            <ul class="nav nav-tabs">
                <li class="active"><b>商品管理</b></li>
            </ul>
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane active in" id="home">
                    <form id="formid" action="/kaola/goodsEdit" method="post">
                        <p>商品名称：<input type="text" value="<?=$getData['goods_title']?>" placeholder="商品名称" style="width:570px" name="goods_title" type='text' class="goods_title"></p>
                        <p style="display:inline">销售价格：<input type="text" value="" placeholder="销售价格" style="width:95px" name="goods_price" type='text' class="goods_price"> 元 &nbsp;
                            / &nbsp;&nbsp;<input type="text" value="<?=$getData['goods_attr']?>" placeholder="件/个等" style="width:40px" name="goods_attr" type='text' class="goods_attr">&nbsp;&nbsp;
                            成本价格：<input type="text" value="{{$getData.goods_price}}" placeholder="成本价格" style="width:80px" name="channel_price" type='text' class="channel_price" readonly> 元
                            &nbsp;盈利预估：<input id="ylz" type="text" style="width: 66px;" disabled value="{{$getData['goods_price']-$getData.channel_price}}" placeholder="盈利预估" name="" class="" /> 元
                        </p>
                        <p>商品分类： <select style="width:120px" id="setChange" name="cate1_id">
                        <?php if($cate){foreach($cate AS $val){?>
                        <option value="<?=$val['cate_id']?>" <?=$val['cate_id'] == $getData['cate1_id'] ? 'selected="selected"' : ''?>><?=$val['cate_name']?></option>
                        <?php }}else{?>
                        <option>没有数据</option>
                        <?php }?>
                        </select>&nbsp;<select style="width:120px" id="applyIn" name="cate2_id"></select>
                        &nbsp;
                            &nbsp;库存：<input type="text" style="width: 80px;" value="{{$getData.store}}" placeholder="库存" name="kcun" class="kcun" />&nbsp;&nbsp;在线状态：<label style="display: inline"><input type="radio" name="status" style="margin-top: 1px" value="0" checked />下线&nbsp;&nbsp;</label><label style="display: inline"><input type="radio" name="status" style="margin-top: 1px" value="1" />上线</label>
                        </p>
                        <p><div id="setImd" style="display:inline">商品图片：<input type="text" placeholder="商品图片" name="goods_pic" class="setImdText" style="width:416px" value="<?=$getData['goods_pic']?>" readonly> <input type="button" class="btn btn-info setImdBtn" style='margin-top:-8px' value="选择图片">&nbsp;<a class="btn btn-warning  picViews" <?=$getData['goods_pic'] ? '' : 'disabled title="暂不可用"'?> url="<?=$getData['goods_pic'] ? transUrl($getData['goods_pic']) : ''?>" style='margin-top:-8px'>查看</a></div></p>
                        <p><div id="setImd1" style="display:inline">商品图2：<input type="text" placeholder="商品图片" name="goods_pic2" class="setImd1Text" style="width:422px" value="<?=$getData['goods_pic2']?>" readonly> <input type="button" class="btn btn-info setImd1Btn" style='margin-top:-8px' value="选择图片">&nbsp;<a class="btn btn-warning  picViews" <?=$getData['goods_pic2'] ? '' : 'disabled title="暂不可用"'?> url="<?=$getData['goods_pic2'] ? transUrl($getData['goods_pic2']) : ''?>" style='margin-top:-8px'>查看</a></div></p>
                        <p><div id="setImd2" style="display:inline">商品图3：<input type="text" placeholder="商品图片" name="goods_pic3" class="setImd2Text" style="width:422px" value="<?=$getData['goods_pic3']?>" readonly> <input type="button" class="btn btn-info setImd2Btn" style='margin-top:-8px' value="选择图片">&nbsp;<a class="btn btn-warning  picViews" <?=$getData['goods_pic3'] ? '' : 'disabled title="暂不可用"'?> url="<?=$getData['goods_pic3'] ? transUrl($getData['goods_pic3']) : ''?>" style='margin-top:-8px'>查看</a></div></p>

                        <p>黄金返利：<input type="text" value="" placeholder="黄金返利" style="width:100px" name="hjprofit" class="hjfl" type='text'> 元&nbsp;&nbsp;&nbsp;
                            白银返利：<input type="text" value="" placeholder="白银返利" style="width:100px" name="byprofit" class="byfl" type='text' readonly> 元&nbsp;&nbsp;&nbsp;
                            钻石返利：<input type="text" value="" placeholder="钻石返利" style="width:100px" name="zsprofit" class="zsfl" type='text' readonly > 元
                        </p>

                        <p><textarea style="width:613px;height:310px;margin-left:73px;margin-top:-20px" name="content"><?=htmlspecialchars_decode($getData['goods_detail'])?></textarea></p>
                        <input type="hidden" value="{{$getData.id}}" name="goods_id" />
                        <input type="hidden" value="1" name="dosubmit" />
                    </form>
                </div>
                <div class="btn-toolbar">
                    <button class="btn btn-primary" id="btn-save" style="margin:18px 0 0 70px"><i class="icon-save"></i> 保存入库</button>
                    <div class="btn-group">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $('#btn-save').click(function(){
            if(!($('.goods_title').val())){
                showmsg('商品名称不能为空');
                return false;
            }else if(!($('.goods_price').val())){
                showmsg('销售价格不能为空');
                return false;
            }else if(!($('.goods_attr').val())){
                showmsg('产品规格不能为空');
                return false;
            }else if(!$('.channel_price').val()) {
                showmsg('成本价格不能为空');
                return false;
            }else if(!$('.kcun').val()) {
                showmsg('库存不能为空');
                return false;
            }else if(!$('.hjfl').val()){
                showmsg('黄金返利不能为空');
                return false;
            }else{
                setBtn($('#btn-save'));
                $('#formid').submit();
            }
        });
        $('.picViews').click(function(){
            var url = $(this).parent().find('a').attr('url');
            if(url != ''){
                showimg(url);
            }
        });
        $('.setImdBtn').click(function(){
            $('#setImd').selfups();
        });
        $('.setImd1Btn').click(function(){
            $('#setImd1').selfups();
        });
        $('.setImd2Btn').click(function(){
            $('#setImd2').selfups();
        });
        $('.hjfl').blur(function(){
            if(isNaN($('.hjfl').val())){
                $('.hjfl').val('');
            }else{
                $.get('/goods/gprice',{'price':$('#ylz').val()},function(data){
                    $('.byfl').val(data.price2);$('.zsfl').val(data.price3);
                },'json');
                mPrice = $('#ylz').val();
            }
        });
        mPrice = $('.goods_price').val() - $('.channel_price').val();
        setInterval(function checkNum(){
            $('#ylz').val(($('.goods_price').val() - $('.channel_price').val()).toFixed(2));
            if(mPrice - $('#ylz').val() > 0 || $('#ylz').val() - mPrice > 0){
                console.log($('#ylz').val());
                $.get('/goods/gprice',{'price':$('#ylz').val()},function(data){
                    $('.byfl').val(data.price2);
                    $('.hjfl').val(data.price1);
                    $('.zsfl').val(data.price3);
                },'json');
                mPrice = $('#ylz').val();
            }
        },100);
        $('#setChange').change(function(){
            optionHtml = '';
            $.get('/goods/cates',{'ajaxFrom':'1','cateid':$(this).val()},function(data){
                if(data.length){
                    for(var i=0;i<data.length;i++){
                        optionHtml += '<option value='+data[i].cate_id+'>'+data[i].cate_name+'</option>';
                    }
                }else{
                    optionHtml = '<option value="0">没有行业数据</option>';

                }
                $('#applyIn').html(optionHtml);
            },'json');
        }).trigger('change');
    });
</script>